let str:string = "hello world"
console.log(str);
// 元组
let arr:[number,string] = [1,"name"]
console.log(arr);
// 枚举
enum sex {
    man="男",
    woman="女",
    secret="未知"

}

let person = {
    name:"张三",
    sex:sex.man
}
console.log(person);
let a:number | string = 1
a="nihu"
console.log(a);
a=123
console.log(a);

(async ()=>{
    let res:number | string
    res = await new Promise((resolve, reject) => {
        resolve(3.1415926)
    })
    console.log((res as number).toFixed(2))
}
)()

let demo:(a:number,b:number)=>number
demo=(x:number,y:number)=>{
    return x+y
}
console.log(demo(8,2));
let demo1:(a:number,b:number)=>number = (x:number,y:number)=>x+y
console.log(demo1(5,9));

function slice(str:string,start:number,end?:number){
    return str.slice(start,end)
}
console.log(slice("你是谁",1));
console.log(slice("你是谁",1,2));



export {}